var express = require('express');

var router = express.Router();
var app = express();

router.use(function(req, resp, next){
    if("false" == req.headers['x-auth']){
        console.log("x-auth is false");
        return next('router');
    }else{
        console.log("x-auth is true");
        next();
    }
});

router.get('/', function(req, resp, next){
    resp.send("Hello,root path.");
});

app.use("/admin", router, function(req, resp){
    resp.sendStatus(401);
})

app.listen(3000, function(){
    console.log("server is running.")
})
